\hypertarget{Vector_8h}{
\section{Source/Vector.h File Reference}
\label{Vector_8h}\index{Source/Vector.h@{Source/Vector.h}}
}
CAN HAS VECTORZ?  




This graph shows which files directly or indirectly include this file:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=62pt]{Vector_8h__dep__incl}
\end{center}
\end{figure}
\subsection*{Data Structures}
\begin{CompactItemize}
\item 
struct \textbf{Vector}
\end{CompactItemize}
\subsection*{Defines}
\begin{CompactItemize}
\item 
\#define \hyperlink{Vector_8h_1d42138b57bae5f6c44603a2eefe1bc1}{Vector\_\-Free}(V)~(Vector\_\-Destroy(V))
\end{CompactItemize}
\subsection*{Functions}
\begin{CompactItemize}
\item 
Vector $\ast$ \hyperlink{Vector_8h_fde51add318e17ab44a3216d994cbbda}{Vector\_\-Create} ()
\item 
void \hyperlink{Vector_8h_138582322ae38e04a493bb55730271b9}{Vector\_\-Destroy} (Vector $\ast$Vector)
\item 
float \hyperlink{Vector_8h_0ff05e265810605087e97faafecabfce}{Vector\_\-Length} (Vector $\ast$Vector)
\item 
void \hyperlink{Vector_8h_46d73be53d9f0aff72c49a1d582138d6}{Vector\_\-Scale} (Vector $\ast$Vector, float Scale)
\item 
void \hyperlink{Vector_8h_5acfb8d122fdc5a801471d51201b291c}{Vector\_\-Normalize} (Vector $\ast$Vector)
\item 
float \hyperlink{Vector_8h_d0bc12e353f57f23fc55ae6c057f4078}{Vector\_\-DotProduct} (Vector $\ast$Vector0, Vector $\ast$Vector1)
\item 
void \hyperlink{Vector_8h_69b2a365d4d6bed0d3a98109ce38ac69}{Vector\_\-CrossProduct} (Vector $\ast$Result, Vector $\ast$Vector0, Vector $\ast$Vector1)
\item 
void \hyperlink{Vector_8h_69bac0172280657626d32d10ea0a2c18}{Vector\_\-Add} (Vector $\ast$Result, Vector $\ast$Vector0, Vector $\ast$Vector1)
\item 
void \hyperlink{Vector_8h_a89c3922a78ccdb0c7a0396cf07ac886}{Vector\_\-Subtract} (Vector $\ast$Result, Vector $\ast$Vector0, Vector $\ast$Vector1)
\end{CompactItemize}


\subsection{Detailed Description}
CAN HAS VECTORZ? 

\begin{Desc}
\item[Author:]Daniel White \end{Desc}
\begin{Desc}
\item[Version:]0.1 \end{Desc}
\hypertarget{Vector_8h_Description}{}\subsection{Description}\label{Vector_8h_Description}
(I'll get round to this) 

Definition in file \hyperlink{Vector_8h-source}{Vector.h}.

\subsection{Define Documentation}
\hypertarget{Vector_8h_1d42138b57bae5f6c44603a2eefe1bc1}{
\index{Vector.h@{Vector.h}!Vector\_\-Free@{Vector\_\-Free}}
\index{Vector\_\-Free@{Vector\_\-Free}!Vector.h@{Vector.h}}
\subsubsection[{Vector\_\-Free}]{\setlength{\rightskip}{0pt plus 5cm}\#define Vector\_\-Free(V)~(Vector\_\-Destroy(V))}}
\label{Vector_8h_1d42138b57bae5f6c44603a2eefe1bc1}


An alias to Vector\_\-Destroy 

Definition at line 23 of file Vector.h.

\subsection{Function Documentation}
\hypertarget{Vector_8h_69bac0172280657626d32d10ea0a2c18}{
\index{Vector.h@{Vector.h}!Vector\_\-Add@{Vector\_\-Add}}
\index{Vector\_\-Add@{Vector\_\-Add}!Vector.h@{Vector.h}}
\subsubsection[{Vector\_\-Add}]{\setlength{\rightskip}{0pt plus 5cm}void Vector\_\-Add (Vector $\ast$ {\em Result}, \/  Vector $\ast$ {\em Vector0}, \/  Vector $\ast$ {\em Vector1})\hspace{0.3cm}{\tt  \mbox{[}inline\mbox{]}}}}
\label{Vector_8h_69bac0172280657626d32d10ea0a2c18}


Caclulates the sum of two vectors.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em Result}]The vector where the result is stored. \item[{\em Vector0}]The first vector. \item[{\em Vector1}]The second vector. \end{description}
\end{Desc}


Definition at line 57 of file Vector.c.

\begin{Code}\begin{verbatim}58 {
59     Result->X=Vector0->X+Vector1->X;
60     Result->Y=Vector0->Y+Vector1->Y;
61     Result->Z=Vector0->Z+Vector1->Z;
62 }
\end{verbatim}
\end{Code}


\hypertarget{Vector_8h_fde51add318e17ab44a3216d994cbbda}{
\index{Vector.h@{Vector.h}!Vector\_\-Create@{Vector\_\-Create}}
\index{Vector\_\-Create@{Vector\_\-Create}!Vector.h@{Vector.h}}
\subsubsection[{Vector\_\-Create}]{\setlength{\rightskip}{0pt plus 5cm}Vector$\ast$ Vector\_\-Create ()\hspace{0.3cm}{\tt  \mbox{[}inline\mbox{]}}}}
\label{Vector_8h_fde51add318e17ab44a3216d994cbbda}


Creates a vector and returns a pointer to it.

\begin{Desc}
\item[Returns:]On success, a pointer to the vector, otherwise a NULL pointer. \end{Desc}


Definition at line 7 of file Vector.c.

\begin{Code}\begin{verbatim}8 {
9     Vector *Vector=malloc(sizeof(Vector));
10     if (Vector!=NULL)
11     {
12         Vector->X=0.0;
13         Vector->Y=0.0;
14         Vector->Z=0.0;
15     }
16     return Vector;
17 }
\end{verbatim}
\end{Code}


\hypertarget{Vector_8h_69b2a365d4d6bed0d3a98109ce38ac69}{
\index{Vector.h@{Vector.h}!Vector\_\-CrossProduct@{Vector\_\-CrossProduct}}
\index{Vector\_\-CrossProduct@{Vector\_\-CrossProduct}!Vector.h@{Vector.h}}
\subsubsection[{Vector\_\-CrossProduct}]{\setlength{\rightskip}{0pt plus 5cm}void Vector\_\-CrossProduct (Vector $\ast$ {\em Result}, \/  Vector $\ast$ {\em Vector0}, \/  Vector $\ast$ {\em Vector1})\hspace{0.3cm}{\tt  \mbox{[}inline\mbox{]}}}}
\label{Vector_8h_69b2a365d4d6bed0d3a98109ce38ac69}


Caclulates the cross product of two vectors.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em Result}]The vector where the result is stored. \item[{\em Vector0}]The first vector. \item[{\em Vector1}]The second vector. \end{description}
\end{Desc}


Definition at line 50 of file Vector.c.

\begin{Code}\begin{verbatim}51 {
52     Result->X=Vector0->Y*Vector1->Z-Vector0->Z*Vector1->Y;
53     Result->Y=Vector0->Z*Vector1->X-Vector0->X*Vector1->Z;
54     Result->Z=Vector0->X*Vector1->Y-Vector0->Y*Vector1->X;
55 }
\end{verbatim}
\end{Code}


\hypertarget{Vector_8h_138582322ae38e04a493bb55730271b9}{
\index{Vector.h@{Vector.h}!Vector\_\-Destroy@{Vector\_\-Destroy}}
\index{Vector\_\-Destroy@{Vector\_\-Destroy}!Vector.h@{Vector.h}}
\subsubsection[{Vector\_\-Destroy}]{\setlength{\rightskip}{0pt plus 5cm}void Vector\_\-Destroy (Vector $\ast$ {\em Vector})\hspace{0.3cm}{\tt  \mbox{[}inline\mbox{]}}}}
\label{Vector_8h_138582322ae38e04a493bb55730271b9}


Destroys a vector, freeing the memory used.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em Vector}]The vector to destroy. \end{description}
\end{Desc}


Definition at line 19 of file Vector.c.

\begin{Code}\begin{verbatim}20 {
21     free(Vector);
22 }
\end{verbatim}
\end{Code}


\hypertarget{Vector_8h_d0bc12e353f57f23fc55ae6c057f4078}{
\index{Vector.h@{Vector.h}!Vector\_\-DotProduct@{Vector\_\-DotProduct}}
\index{Vector\_\-DotProduct@{Vector\_\-DotProduct}!Vector.h@{Vector.h}}
\subsubsection[{Vector\_\-DotProduct}]{\setlength{\rightskip}{0pt plus 5cm}float Vector\_\-DotProduct (Vector $\ast$ {\em Vector0}, \/  Vector $\ast$ {\em Vector1})\hspace{0.3cm}{\tt  \mbox{[}inline\mbox{]}}}}
\label{Vector_8h_d0bc12e353f57f23fc55ae6c057f4078}


Caclulates the dot product of two vectors.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em Vector0}]The first vector. \item[{\em Vector1}]The second vector. \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]The dot product of the vectors. \end{Desc}


Definition at line 45 of file Vector.c.

\begin{Code}\begin{verbatim}46 {
47     return Vector0->X*Vector1->X+Vector0->Y*Vector1->Y+Vector0->Z*Vector1->Z;
48 }
\end{verbatim}
\end{Code}


\hypertarget{Vector_8h_0ff05e265810605087e97faafecabfce}{
\index{Vector.h@{Vector.h}!Vector\_\-Length@{Vector\_\-Length}}
\index{Vector\_\-Length@{Vector\_\-Length}!Vector.h@{Vector.h}}
\subsubsection[{Vector\_\-Length}]{\setlength{\rightskip}{0pt plus 5cm}float Vector\_\-Length (Vector $\ast$ {\em Vector})\hspace{0.3cm}{\tt  \mbox{[}inline\mbox{]}}}}
\label{Vector_8h_0ff05e265810605087e97faafecabfce}


Calculates the length, or magntiude of a vector.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em Vector}]The vector to get the length of. \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]The length. \end{Desc}


Definition at line 24 of file Vector.c.

\begin{Code}\begin{verbatim}25 {
26     return sqrt(Vector->X*Vector->X+Vector->Y*Vector->Y+Vector->Z*Vector->Z);
27 }
\end{verbatim}
\end{Code}


\hypertarget{Vector_8h_5acfb8d122fdc5a801471d51201b291c}{
\index{Vector.h@{Vector.h}!Vector\_\-Normalize@{Vector\_\-Normalize}}
\index{Vector\_\-Normalize@{Vector\_\-Normalize}!Vector.h@{Vector.h}}
\subsubsection[{Vector\_\-Normalize}]{\setlength{\rightskip}{0pt plus 5cm}void Vector\_\-Normalize (Vector $\ast$ {\em Vector})\hspace{0.3cm}{\tt  \mbox{[}inline\mbox{]}}}}
\label{Vector_8h_5acfb8d122fdc5a801471d51201b291c}


Normalizes a vector (makes its length equal to 1).

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em Vector}]The vector to normalize. \end{description}
\end{Desc}


Definition at line 37 of file Vector.c.

\begin{Code}\begin{verbatim}38 {
39     float ReciprocalLength=1/Vector_Length(Vector);
40     Vector->X*=ReciprocalLength;
41     Vector->Y*=ReciprocalLength;
42     Vector->Z*=ReciprocalLength;
43 }
\end{verbatim}
\end{Code}


\hypertarget{Vector_8h_46d73be53d9f0aff72c49a1d582138d6}{
\index{Vector.h@{Vector.h}!Vector\_\-Scale@{Vector\_\-Scale}}
\index{Vector\_\-Scale@{Vector\_\-Scale}!Vector.h@{Vector.h}}
\subsubsection[{Vector\_\-Scale}]{\setlength{\rightskip}{0pt plus 5cm}void Vector\_\-Scale (Vector $\ast$ {\em Vector}, \/  float {\em Scale})\hspace{0.3cm}{\tt  \mbox{[}inline\mbox{]}}}}
\label{Vector_8h_46d73be53d9f0aff72c49a1d582138d6}


Scales a vector by the given float (also known as scalar multiplication).

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em Vector}]The vector to scale. \item[{\em Scale}]The factor to scale by. \end{description}
\end{Desc}


Definition at line 30 of file Vector.c.

\begin{Code}\begin{verbatim}31 {
32     Vector->X*=Scale;
33     Vector->Y*=Scale;
34     Vector->Z*=Scale;
35 }
\end{verbatim}
\end{Code}


\hypertarget{Vector_8h_a89c3922a78ccdb0c7a0396cf07ac886}{
\index{Vector.h@{Vector.h}!Vector\_\-Subtract@{Vector\_\-Subtract}}
\index{Vector\_\-Subtract@{Vector\_\-Subtract}!Vector.h@{Vector.h}}
\subsubsection[{Vector\_\-Subtract}]{\setlength{\rightskip}{0pt plus 5cm}void Vector\_\-Subtract (Vector $\ast$ {\em Result}, \/  Vector $\ast$ {\em Vector0}, \/  Vector $\ast$ {\em Vector1})\hspace{0.3cm}{\tt  \mbox{[}inline\mbox{]}}}}
\label{Vector_8h_a89c3922a78ccdb0c7a0396cf07ac886}


Caclulates the difference between two vectors.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em Result}]The vector where the result is stored. \item[{\em Vector0}]The first vector. \item[{\em Vector1}]The second vector. \end{description}
\end{Desc}


Definition at line 64 of file Vector.c.

\begin{Code}\begin{verbatim}65 {
66     Result->X=Vector0->X-Vector1->X;
67     Result->Y=Vector0->Y-Vector1->Y;
68     Result->Z=Vector0->Z-Vector1->Z;
69 }
\end{verbatim}
\end{Code}


